package com.puman.dao.impl;

import java.util.List;
import java.util.Map;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Repository;

import com.core.BaseDaoImpl;
import com.core.Pager;
import com.puman.bean.Staff;
import com.puman.bean.Tank;
import com.puman.dao.TankDao;

@Repository("tankDao")
public class TankDaoImpl extends BaseDaoImpl<Tank> implements TankDao {

	@Override
	public List<Tank> getList(Integer supplier_id) {
		String hql = "select t.id,t.tank_num,t.gasstation_id,g.name as GASSTATION_NAME,t.gas_type,t.volume,"+
				"t.create_date,t.create_user_id,t.create_user_name,"+
				"t.modify_date,t.modify_user_id,t.modify_user_name "+ 
				" from m_gasstation_tank t left join m_Gasstation g on t.GASSTATION_ID = g.ID "+
				" where 1=1 and t.GASSTATION_ID in (select ID from m_Gasstation where SUPPLIER_ID = "+ supplier_id + ") order by t.modify_date desc";
			List<Tank> list = getSession().createSQLQuery(hql).addEntity(Tank.class).list();
			return list;
	}
	
	public List<Tank> getListLike(Integer supplier_id,String name){
		String hql = "select t.id,t.tank_num,t.gasstation_id,g.name as GASSTATION_NAME,t.gas_type,t.volume,"+
				"t.create_date,t.create_user_id,t.create_user_name,"+
				"t.modify_date,t.modify_user_id,t.modify_user_name "+ 
				" from m_gasstation_tank t left join m_Gasstation g on t.GASSTATION_ID = g.ID "+
				" where 1=1 and t.GASSTATION_ID in (select ID from m_Gasstation where SUPPLIER_ID = "+ supplier_id + ")"+
				" and t.TANK_NUM like '%"+name+"%' order by t.modify_date desc";
			List<Tank> list = getSession().createSQLQuery(hql).addEntity(Tank.class).list();
			return list;
	}
}
